﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.DataModel;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YArchitech.HVAC
{
	public partial class FormConnAlign : System.Windows.Forms.Form
	{
		public int AlignType { get; set; }

		public FormConnAlign()
		{
			this.InitializeComponent();
			//base.Icon = Resource.YArchitechIcon;
		}

		private void FormConnAlign_Load(object sender, EventArgs e)
		{
			this.UserSettingRead();
		}

		private void btnSure_Click(object sender, EventArgs e)
		{
			if (this.rdoTop.Checked)
			{
				this.AlignType = 0;
			}
			else if (this.rdoMiddle.Checked)
			{
				this.AlignType = 1;
			}
			else if (this.rdoBottom.Checked)
			{
				this.AlignType = 2;
			}
			this.UserSettingWrite();
			base.DialogResult = DialogResult.OK;
		}

		private void UserSettingWrite()
		{
			this.userSetting.WriteTerminalAlignType(this.AlignType.ToString());
		}

		private void UserSettingRead()
		{
			string terminalAlignType = this.userSetting.GetTerminalAlignType();
			if (terminalAlignType == "0")
			{
				this.rdoTop.Checked = true;
				return;
			}
			if (terminalAlignType == "2")
			{
				this.rdoBottom.Checked = true;
				return;
			}
			this.rdoMiddle.Checked = true;
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
		}

		private HVACUserSetting userSetting = new HVACUserSetting();
	}
}
